#ifndef __SCHEMATIC__
#define __SCHEMATIC__

#include <string>
#include <map>
#include <vector>
#include <wx\thread.h>

#include "..\Math\Point2.h"
#include "..\Math\Point3.h"
#include "..\Paril\Minecraft\NBT\NBTFile.h"
#include "Block.h"

class RendererBase;
class Chunk;

class Schematic
{
	typedef Point2<uint16_t> Point2us;
	std::map<Point2us, Chunk*> _chunks;
	std::map<int, NBTTagBase*> _tileEntTags;
	const NBTTagList<byte, TAG_Byte> *_blockData, *_dataData;
	wxMutex _mutex;
	RendererBase *_renderer;

public:	
	int Width;
	int Length;
	int Height;

	int WidthInChunks, LengthInChunks, TotalChunks;
	bool Loaded;

	Schematic(const std::string &fileName, RendererBase *renderer);

	inline Chunk *GetChunk(const Point2us &pt, const bool &doLoad = true);
	const NBTTagBase *GetTileEntity(const int &x, const int &y, const int &z);
	const Block &GetBlock(const int &x, const int &y, const int &z);
	const Block &GetBlock(const int &x, const int &y, const int &z, const bool &forceLoad);
	inline const Block &GetBlock(const Point3i &b) { return GetBlock(b.X, b.Y, b.Z); }
	bool IsOpaqueBlockAt(const int &x, const int &y, const int &z);
	bool IsFullBlockAt(const int &x, const int &y, const int &z);

	void LoadFromFile(const std::string &fileName);
};
#else
class Schematic;
#endif